/*************************************************************************
	> File Name: P1218.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2024-12-16 11:42:56
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int arr[10];
int n;

void output() {
    for (int i = 1; i <= n; i++) {
        cout << arr[i];
    }
    cout << endl;
    return ;
}

int is_prime(int n) {
    if (n == 1) return 0;
    for (int i = 2, I = sqrt(n); i <= I; i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

void dfs(int len, int val) {
    if (len > n) {
        output();
        return ;
    }
    for (int i = 1; i <= 9; i++) {
        if (!is_prime(val * 10 + i)) continue;
        arr[len] = i;
        dfs(len + 1, val * 10 + i);
    }
    return ;
}

int main() {
    cin >> n;
    dfs(1, 0);
    return 0;
}
